<style scoped>
  @import "category-edit.css";
</style>
<template>
  <div>


      <Card v-for="(item,index) in cdata.list" class="banner-edit-card" style="">
        <Input class="input-item" type="text" v-model="item.title" style="width: 230px;margin: 2px;" placeholder="不填则不显示">
          <span slot="prepend">标题:</span>
        </Input>
        <QActionEdit :flag="index" @action-data-change="selected" :init-item="item"></QActionEdit>
        <div class="banner-edit-del-wrap">
          <Icon type="ios-trash-outline" class="banner-edit-del" :size="26" @click.native="del(index)"></Icon>
        </div>

      </Card>
    <div class="add-wrap">
      <Button @click="add" class="add-btn">
        <Icon type="md-add-circle" size="20"/>
      </Button>
    </div>
  </div>

</template>
<script>
  import QActionEdit from '../../action-edit'
  export default {
    name: 'qcategory-edit',
    props: {
      cdata: {
        type: Object,
        default: function () {
          return {list: []};
        }
      }
    },
    components: {
        QActionEdit
    },
    data() {
      return {}
    },
    created(){
    },
    methods: {
        selected(data) {
            this.cdata.list[data.flag] = data.data;
        },
        add() {
            this.cdata.list.push({type: 0,img:[],title:''})
        },
        del(index) {
            this.cdata.list.splice(index, 1);
        }
    }
  }
</script>
